package com.csg.ses.service.ses.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.csg.ses.dao.ses.SysUserLoginDao;
import com.csg.ses.entity.ses.SysUserLoginEntity;
import com.csg.ses.service.ses.SysUserLoginService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 登录信息
 * @author wangjun
 * @date 2020/11/16
 */
@Service
@RequiredArgsConstructor
public class SysUserLoginServiceImpl extends ServiceImpl<SysUserLoginDao, SysUserLoginEntity> implements SysUserLoginService {
    private final SysUserLoginDao sysUserLoginDao;

    @Override
    public SysUserLoginEntity getUserLogin(SysUserLoginEntity userLogin) {
        QueryWrapper<SysUserLoginEntity> qw = new QueryWrapper();
        qw.eq("login_code", userLogin.getLoginCode());
        return sysUserLoginDao.selectOne(qw);
    }

    @Override
    public SysUserLoginEntity getByLoginCode(String loginCode) {
        QueryWrapper<SysUserLoginEntity> qw = new QueryWrapper();
        qw.eq("login_code", loginCode);
        return sysUserLoginDao.selectOne(qw);
    }

    @Override
    public void modifyPwd(SysUserLoginEntity user, String newPwd) {
        user.setLoginPwd(newPwd);
        sysUserLoginDao.updateById(user);
    }
}